<template>
  <div class="container">
    <conditionGroup :floor="floor" :conditionList="conditionList" :parentData="this" :key-list="keyOptions" :condition-map="conditionOptions" :val-list="valueOptions"> </conditionGroup>

    <el-button type="primary" @click="query">查询</el-button>
  </div>
</template>

<script>
import conditionGroup from './conditionGroup'

const condition = {
  id: 1, // 对象id（自增）
  index: 1, // 索引值
  condition: '', // 运算符
  operate: 'and', // 且/或
  field: '', // 字段名
  value: '', // 值
  header: true, // 值
  checked: false, // 是否选中
  pid: -1, // 前端值
  floor: 1 // 分组使用（暂时不管）
}

export default {
  name: 'demo',
  components: {
    conditionGroup
  },
  data () {
    return {
      conditionList: [
        Object.assign({}, condition)
      ],
      floor: 1,

      keyOptions: [
        {'key': 'ID', 'val': 'id'},
        {'key': '名称', 'val': 'name'},
        {'key': '类型', 'val': 'type'},
        {'key': '来源', 'val': 'source'},
        {'key': '昵称', 'val': 'nick_name'},
        {'key': '创建时间', 'val': 'create_time'},
        {'key': '更新时间', 'val': 'update_time'}
      ],
      conditionOptions: {
        type: [
          {'key': '=', 'val': 'eq'}
        ],
        source: [
          {'key': '=', 'val': 'eq'}
        ]
      },
      valueOptions: {
        type: {
          dom: 'select',
          data: [
            {'key': 'time', 'val': 'time'},
            {'key': 'date', 'val': 'date'}
          ]
        },
        source: {
          dom: 'select',
          data: [
            {'key': 'm1', 'val': 'm'},
            {'key': 'a1', 'val': 'a'}
          ]
        },
        create_time: {
          dom: 'date'
        },
        update_time: {
          dom: 'date'
        }
      }
    }
  },
  created () {

  },
  methods: {
    query () {
      console.log(this.conditionList)
    }
  }
}
</script>

<style scoped>

</style>
